package win.lioil.bluetooth;

import android.annotation.SuppressLint;
import android.app.Application;
import android.os.Handler;
import android.widget.Toast;

import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

public class APP extends Application {
    private static final Handler sHandler = new Handler();
    private static Toast sToast; // 单例Toast,避免重复创建，显示时间过长

    public static String[] permission = {
            android.Manifest.permission.BLUETOOTH_SCAN,
            android.Manifest.permission.BLUETOOTH_ADVERTISE,
            android.Manifest.permission.BLUETOOTH_CONNECT,
            android.Manifest.permission.ACCESS_COARSE_LOCATION,
            android.Manifest.permission.ACCESS_FINE_LOCATION};


    public final static int BufferLen = 8192 * 64;
    public final static int ReadLen = 61;
    public static int FillRound = 0;
    public static int FillIndex = 0;
    public static int DisplayIndex = 0;
    public static float[] I = new float[BufferLen];
    public static float[] II = new float[BufferLen];
    public static float[] III = new float[BufferLen];
    public static float[] AVR = new float[BufferLen];
    public static float[] AVL = new float[BufferLen];
    public static float[] AVF = new float[BufferLen];

    @SuppressLint("ShowToast")
    @Override
    public void onCreate() {
        super.onCreate();
        sToast = Toast.makeText(this, "", Toast.LENGTH_SHORT);
    }

    public static void toast(String txt, int duration) {
        sToast.setText(txt);
        sToast.setDuration(duration);
        sToast.show();
    }

    public static void runUi(Runnable runnable) {
        sHandler.post(runnable);
    }
}
